/**
 * 智慧小区管理系统 - 支付模块类型定义
 * @author Wu.Liang
 * @date 2025-06-26
 * @version 3.0 - 根据系统设计调整方案重构，统一支付接口
 */

// 基础查询参数 - 根据新接口调整
export interface BaseQueryParams {
  current?: number
  size?: number
  keyword?: string | undefined
  startDate?: string | undefined
  endDate?: string | undefined
  orderBy?: string | undefined
  orderDirection?: string | undefined
}

// 支付查询参数 - 根据新接口调整
export interface PaymentQueryParams extends BaseQueryParams {
  userId?: number | undefined
  communityId?: number | undefined
  paymentMethod?: number | undefined
  paymentStatus?: number | undefined
  businessType?: number | undefined
  businessOrderId?: number | undefined
}

// 支付方式枚举 - 根据新接口调整
export enum PaymentMethod {
  WECHAT = 1,    // 微信支付
  ALIPAY = 2,    // 支付宝
  BANK_CARD = 3, // 银行卡
  CASH = 4       // 现金
}

// 支付状态枚举 - 根据新接口调整
export enum PaymentStatus {
  PENDING = 1,    // 待支付
  PROCESSING = 2, // 支付中
  SUCCESS = 3,    // 支付成功
  FAILED = 4,     // 支付失败
  REFUNDED = 5    // 已退款
}

// 业务类型枚举 - 根据新接口调整
export enum BusinessType {
  PROPERTY_FEE = 1,  // 物业费
  PARKING_FEE = 2,   // 停车费
  UTILITY_FEE = 3,   // 水电费
  OTHER = 4          // 其他
}

// 支付数据传输对象 - 根据新接口调整
export interface PaymentDTO {
  id?: number
  userId: number
  communityId: number
  orderNo?: string
  amount: number
  paymentMethod: number
  paymentStatus?: number
  channelCode?: string
  thirdPartyOrderNo?: string
  paymentTime?: string
  description?: string
  businessType: number
  businessOrderId: number
  refundAmount?: number
  refundReason?: string
  refundTime?: string
  current?: number
  size?: number
}

// 支付视图对象 - 根据新接口调整
export interface PaymentVO {
  id: number
  userId: number
  userName: string
  communityId: number
  communityName: string
  orderNo: string
  amount: number
  paymentMethod: number
  paymentMethodName: string
  paymentStatus: number
  paymentStatusName: string
  channelCode?: string
  thirdPartyOrderNo?: string
  paymentTime?: string
  description?: string
  businessType: number
  businessTypeName: string
  businessOrderId: number
  refundAmount?: number
  refundReason?: string
  refundTime?: string
  createTime: string
  updateTime: string
  createBy?: string
  updateBy?: string
  remark?: string
  canRefund: boolean
  isRefunded: boolean
  statusColor: string
  paymentMethodIcon: string
  formattedAmount: string
  formattedRefundAmount?: string
  statusTag: string
}

// 创建支付订单参数 - 根据新接口调整
export interface CreatePaymentParams {
  userId: number
  communityId: number
  amount: number
  paymentMethod: number
  businessType: number
  businessOrderId: number
  description?: string
}

// 支付回调参数 - 根据新接口调整
export interface PaymentCallbackParams {
  orderNo: string
  paymentStatus: number
  thirdPartyOrderNo?: string
  paymentTime?: string
  errorMessage?: string
}

// 退款参数 - 根据新接口调整
export interface RefundParams {
  paymentId: number
  refundAmount: number
  refundReason: string
  remark?: string
}

// 支付统计 - 保持兼容
export interface PaymentStatistics {
  totalAmount: number
  totalCount: number
  successAmount: number
  successCount: number
  failedAmount: number
  failedCount: number
  refundAmount: number
  refundCount: number
  methodStats: Array<{
    method: number
    methodName: string
    amount: number
    count: number
    percentage: number
  }>
  businessStats: Array<{
    businessType: number
    businessTypeName: string
    amount: number
    count: number
    percentage: number
  }>
  dailyStats: Array<{
    date: string
    amount: number
    count: number
  }>
}

// 支付渠道配置 - 保持兼容
export interface PaymentChannel {
  id: number
  channelCode: string
  channelName: string
  channelType: number
  appId?: string
  appSecret?: string
  merchantId?: string
  privateKey?: string
  publicKey?: string
  notifyUrl?: string
  returnUrl?: string
  isEnabled: boolean
  sortOrder: number
  createTime: string
  updateTime: string
}

// 退款记录 - 保持兼容
export interface RefundRecord {
  id: number
  paymentId: number
  orderNo: string
  refundNo: string
  refundAmount: number
  refundReason: string
  refundStatus: number
  refundStatusName: string
  thirdPartyRefundNo?: string
  operatorId: number
  operatorName: string
  remark?: string
  createTime: string
}

// 支付通知 - 保持兼容
export interface PaymentNotification {
  id: number
  userId: number
  userName: string
  orderNo: string
  amount: number
  paymentMethod: number
  paymentMethodName: string
  businessType: number
  businessTypeName: string
  notificationType: number
  notificationTypeName: string
  content: string
  isRead: boolean
  createTime: string
}

// 基础响应类型 - 保持兼容
export interface ApiResponse<T = unknown> {
  code: number
  message: string
  data: T
  success?: boolean
}

// 分页响应类型 - 保持兼容
export interface PageResponse<T = any> {
  records: T[]
  total: number
  size: number
  current: number
  pages: number
} 